<template>
  <div>
    <FormPanel ref="formPanel" :list="formList" @formChange="formChangeHandle" :isSubmitBtn="false" :collapse="false" labelWidth="110" />

    <div
      :style="{
        position: 'absolute',
        left: 0,
        bottom: 0,
        right: 0,
        zIndex: 9,
        borderTop: '1px solid #e9e9e9',
        padding: '10px 20px',
        background: '#fff',
        textAlign: 'center'
      }"
    >
      <multiuse-button size="small" type="primary" :click="saveHandle">确 定</multiuse-button>
      <el-button @click="closeDrawer">关 闭</el-button>
    </div>
  </div>
</template>
<script>
import { dictionary } from '@/utils/dictMixin';
import { saveData } from '@/api/omFinance/RebateManage/RebateStatementGenerate';

export default {
  mixins: [dictionary],
  data() {
    this.saveData = null;
    return {
      formList: this.createdFrom(),
      list: []
    };
  },
  created() {},
  methods: {
    formChangeHandle(val) {
      this.saveData = val;
    },
    async saveHandle() {
      this.$refs.formPanel.SUBMIT_FORM();
      if (this.saveData !== null) {
        const res = await saveData(this.saveData);
        if (res.resultCode == 200) {
          this.$notify.success({
            title: '提示信息',
            message: '操作成功'
          });
          this.$emit('close', false, 'refresh');
        }
      }
    },
    closeDrawer() {
      this.$emit('close', false);
    },

    createdFrom() {
      return [
        {
          type: 'SELECT',
          label: '对账分类',
          fieldName: 'verifyType',
          placeholder: '请选择',
          itemList: this.createDictList('6086'),
          rules: [{ required: true, message: '请选择', trigger: 'change' }]
        },
        {
          // TODO arcfox 没有动力形式，记得注释；现在北汽只有新能源好用；
          type: 'SELECT',
          label: '动力形式',
          fieldName: 'powerType',
          placeholder: '请选择',
          itemList: this.createDictList('6008'),
          rules: [{ required: true, message: '请选择', trigger: 'change' }]
        }
      ];
    }
  }
};
</script>
